package 传智题型;

public class 盛最多水的容器 {
    public static void main(String args[]){
        int[] height = {1,8,6,2,5,4,8,3,7};

        int i = 0;
        int j = height.length - 1;
        int Maxcapacity = 0;
        while (i < j) {
            int w = Math.min(height[i],height[j]) * (j - i);
            Maxcapacity = w > Maxcapacity ? w : Maxcapacity;
            if (height[i] < height[j]) {
                i++;
            }else {
                j--;
            }
        }
        System.out.println(Maxcapacity);
    }
}
